function [C Ceq] = NLCon_UB(State, State_PROB, ...
                            OP_Bid, K, CPFlag, TTM, S0, S0_ADJ, RF, DY, TC, ...
                            AllSlope, TP)      
% The code is based on the following paper:
%   Chen, T. Y., Lin, Y. L., and Tzeng, L. Y., forthcoming.
%   Estimating probability weighting functions through option pricing bounds. Review of Asset Pricing Studies.
%
% Copyright: Tzu-Ying Chen, Yo-Lan Lin, Larry Y. Tzeng
% Date: January 30, 2024
                        
% Expected Utility 
OP_UB_EU = RDEU_OP_UB(State, State_PROB, ...
                      K, CPFlag, TTM, S0, S0_ADJ, RF, DY, TC, ...
                      1, 1);
               
% Rank-Dependent Expected Utility
OP_UB = RDEU_OP_UB_PL(State, State_PROB, ...
                      K, CPFlag, TTM, S0, S0_ADJ, RF, DY, TC, ...
                      AllSlope, TP);
OP_UB = max(OP_UB, OP_UB_EU);                                              
OP_UB = max(OP_UB, 0);                                                          

CR = sum(OP_UB >= OP_Bid');
CR = CR / length(K);                                                       

C = [];
Ceq = CR - 1;                                                              